package com.lagou.filter;

import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.rpc.*;
import utils.IPHolder;

import javax.servlet.http.HttpServletRequest;

@Activate(group = CommonConstants.CONSUMER)
public class TransportIpFilter implements Filter {

    @Override
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
        RpcContext.getContext().setAttachment("client_ip",IPHolder.getIp());
        return invoker.invoke(invocation);
    }
}
